

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:rms_mobile_client/Bloc/Storage/IDataContext.dart';
import 'package:rms_mobile_client/StateManagement/ModelProvider.dart';

class UserCenterPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _UserCenterPageState();

}

class _UserCenterPageState extends State<UserCenterPage> {
  @override
  Widget build(BuildContext context) {
    return ModelDescendant<IDataContext>(
			onUpdate: (context, _, data) => ListView(
				padding: EdgeInsets.all(0.0),
				children: <Widget>[
					Container(
						padding: EdgeInsets.symmetric(vertical: 20.0),
						margin: EdgeInsets.all(10.0).copyWith(top: 0.0),
						decoration: BoxDecoration(
								borderRadius: BorderRadius.only(bottomLeft: Radius.circular(15.0), bottomRight: Radius.circular(15.0)),
								color: Color(0x08000000)
						),
					),
					Container(
							padding: EdgeInsets.symmetric(vertical: 20.0),
							margin: EdgeInsets.all(10.0).copyWith(top: 0.0),
							decoration: BoxDecoration(
									borderRadius: BorderRadius.circular(15.0),
									color: Color(0x08000000)
							),
							child: Column(
								mainAxisSize: MainAxisSize.min,
								children: <Widget>[
									CircleAvatar(
										radius: 60.0,
										backgroundColor: Color(0x08000000),
										child: Image.asset("assets/pictures/boy.png", height: 90.0,),
									),
									SizedBox(height: 5.0,),
									Text("خۇش كېلىپسىز ${data.currentUser.name}", style: TextStyle(color: Theme.of(context).primaryColor),),
									SizedBox(height: 5.0,),
									RaisedButton(
//											color: Colors.redAccent,
										child: Text("چىكىنىش",),
										onPressed: (){
											exit(0);
										},
										shape: RoundedRectangleBorder(
												borderRadius: BorderRadius.circular(8.0)
										),
									)
								],
							)
					),
					Container(
						padding: EdgeInsets.symmetric(vertical: 20.0),
						margin: EdgeInsets.all(10.0).copyWith(top: 0.0),
						decoration: BoxDecoration(
								borderRadius: BorderRadius.circular(15.0),
								color: Color(0x08000000)
						),
						child: Column(
							children: <Widget>[
								_buildDwiderOptionItem(title: "خاتېرە", subTitle: "بۇ يەردىن سودا خاتېرىسىنى كۆرەلەيسىز", iconData: Icons.history, onTap: (){}),
								Divider(),
								_buildDwiderOptionItem(title: "ئۈستەل ۋە رايۇن باشقۇرۇش", subTitle: "بۇ يەردىن رايۇن ۋە ئۈستەللەرنى باشقۇرالايسىز", iconData: Icons.table_chart, onTap: (){}),
								Divider(),
								_buildDwiderOptionItem(title: "ئىشلەتكۈچىلەر باشقۇرۇش", subTitle: "ئىشلەتكۈچىلەر ھىساباتى باشقۇرۇش", iconData: Icons.account_circle, onTap: (){}),
								Divider(),
								_buildDwiderOptionItem(title: "يىمەكلىك تۈرى باشقۇرۇش", subTitle: "يىمكلىك تۈرلىرىنى قوشالايسىز ياكى چىقىرۋىتەلەيسىز", iconData: Icons.free_breakfast, onTap: (){}),
								Divider(),
								_buildDwiderOptionItem(title: "تەڭشەكلەر", subTitle: "سىستېما تەڭشەكلىرى", iconData: Icons.settings, onTap: (){}),
							],
						),
					)
				],
			),
		);
  }

	Widget _buildDwiderOptionItem({@required String title, @required String subTitle, @required IconData iconData, @required void Function() onTap}){
		return ListTile(
			title: Text(title),
			subtitle: Text(subTitle),
			leading: Container(
				child: Icon(iconData, size: 30.0,),
				decoration: BoxDecoration(
						shape: BoxShape.circle,
						color: Color(0x08000000)
				),
				padding: EdgeInsets.all(10.0),
			),
			onTap: onTap,
		);
	}
}